/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package east2west.service;

import east2west.dao.AccountDAO;
import east2west.dao.FunctionDAO;
import east2west.dao.RoleDAO;
import east2west.dao.RoleFunctionDAO;
import east2west.dto.AccountDTO;
import east2west.dto.FunctionDTO;
import east2west.dto.RoleDTO;
import east2west.dto.RoleFunctionDTO;
import java.util.ArrayList;

/**
 *
 * @author anhtuan
 */
public class AdminServicer {

    AccountDAO accDAO = new AccountDAO();
    FunctionDAO funcDAO = new FunctionDAO();
    RoleDAO roleDAO = new RoleDAO();
    RoleFunctionDAO rolefunctionDao = new RoleFunctionDAO();

    public String getPassword(String usename) {
        return accDAO.readPassWord(usename);
    }

    public AccountDTO findByUsename(String usename) {
        return accDAO.findByUserName(usename);
    }

    public ArrayList<FunctionDTO> findFunctionByRoleID(int roleID) {
        return funcDAO.findByRoleId(roleID);
    }

    public ArrayList<AccountDTO> readByAllAccount() {
        return accDAO.readByAll();
    }

    public ArrayList<RoleDTO> readByAllRole() {
        return roleDAO.readByAll();
    }

    public boolean createAccount(AccountDTO dto) {
        return accDAO.create(dto);
    }

    public boolean updateAccount(AccountDTO dto) {
        return accDAO.update(dto);
    }

    public boolean deleteAccount(String username) {
        return accDAO.delete(username);
    }

    public ArrayList<FunctionDTO> readByAllFunction() {
        return funcDAO.readByAll();
    }

    public RoleDTO readRoleById(int parseInt) {
        return roleDAO.findById(parseInt);
    }

    public ArrayList<RoleFunctionDTO> readRoleFunctionByRoleId(int RoleId) {
        return rolefunctionDao.readByRoleId(RoleId);
    }
}
